/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Gleydson
 */
@Entity
@Table(name = "professor_reserva_equipamento")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ProfessorReservaEquipamento.findAll", query = "SELECT p FROM ProfessorReservaEquipamento p"),
    @NamedQuery(name = "ProfessorReservaEquipamento.findByLogin", query = "SELECT p FROM ProfessorReservaEquipamento p WHERE p.login = :login")})
public class ProfessorReservaEquipamento implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "login")
    private String login;
    @JoinColumn(name = "login", referencedColumnName = "login", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Professor professor;
    @JoinColumn(name = "equipamento", referencedColumnName = "numero_patrimonio")
    @ManyToOne(optional = false)
    private Equipamento equipamento;

    public ProfessorReservaEquipamento() {
    }

    public ProfessorReservaEquipamento(String login) {
        this.login = login;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public Professor getProfessor() {
        return professor;
    }

    public void setProfessor(Professor professor) {
        this.professor = professor;
    }

    public Equipamento getEquipamento() {
        return equipamento;
    }

    public void setEquipamento(Equipamento equipamento) {
        this.equipamento = equipamento;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (login != null ? login.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProfessorReservaEquipamento)) {
            return false;
        }
        ProfessorReservaEquipamento other = (ProfessorReservaEquipamento) object;
        if ((this.login == null && other.login != null) || (this.login != null && !this.login.equals(other.login))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.ProfessorReservaEquipamento[ login=" + login + " ]";
    }
    
}
